import { serverTime } from '@/services/common';

export default {
    namespace: 'common',

    state: {
        serverTime: {
            date: '',
            timestamp: 0,
        },
    },

    effects: {
        *serverTime({ payload }, { call, put }) {
            const response = yield call(serverTime, payload);
            yield put({
                type: 'saveServerTime',
                payload: response,
            });
            return response.data;
        },
    },

    reducers: {
        saveServerTime(state, { payload }) {
            return {
                ...state,
                serverTime: payload.data,
            };
        },
    },
};
